#include <ros/ros.h>
#include <nav_msgs/OccupancyGrid.h>

int main(int argc, char* argv[])
{
    setlocale(LC_ALL, "zh_CN.utf-8");
    ros::init(argc, argv, "map_pub_node");
    ros::NodeHandle nh;
    ros::Publisher pub = nh.advertise<nav_msgs::OccupancyGrid>("/map", 10);
    ros::Rate rate(1);
    nav_msgs::OccupancyGrid msgs;
    while (ros::ok())
    {
        msgs.header.frame_id = "map";
        msgs.header.stamp = ros::Time::now();
        msgs.info.origin.position.x = 0;
        msgs.info.origin.position.y = 0;
        msgs.info.resolution = 1.0;
        msgs.info.width  = 4;
        msgs.info.height = 2;

        msgs.data.resize(4 * 2);
        msgs.data[0] = 100;
        msgs.data[1] = 100;
        msgs.data[2] = 0;
        msgs.data[3] = -1;
         pub.publish(msgs);
        rate.sleep();
    } 
    return 0;
}